package com.salt.modules.log.model.data;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

/**
 * @Description 登录日志
 * @Author salt
 * @Date 2023/4/20
 * @Version 1.0.1
 */
@Data
@Document(indexName = "login_record", type = "_doc", createIndex = true)
public class LoginRecord implements Serializable {

    @Id
    @Field(index = true, store = true, type = FieldType.Long)
    private Long id;

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String userName;  // 用户账号

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String operRealName;  // 操作人姓名

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String operUserId;  // 操作人ID

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String status;  // 状态 0成功 1失败

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String url;  // 操作的url

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String ip;   // 操作的iP

    @Field(index = false, store = true, type = FieldType.Text)
    private String msg;  // 描述

    @Field(index = true, store = true, type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    private String accessTime;  // 访问时间

    @Field(index = true, store = true, type = FieldType.Keyword)
    private String logType;

}
